package org.jivesoftware.smack.packet;

public class PrivacyItem
{
  private boolean allow;
  private boolean filterIQ = false;
  private boolean filterMessage = false;
  private boolean filterPresence_in = false;
  private boolean filterPresence_out = false;
  private int order;
  private PrivacyRule rule;

  public PrivacyItem(String paramString, boolean paramBoolean, int paramInt)
  {
    setRule(PrivacyRule.fromString(paramString));
    setAllow(paramBoolean);
    setOrder(paramInt);
  }

  private PrivacyRule getRule()
  {
    return this.rule;
  }

  private void setAllow(boolean paramBoolean)
  {
    this.allow = paramBoolean;
  }

  private void setOrder(int paramInt)
  {
    this.order = paramInt;
  }

  private void setRule(PrivacyRule paramPrivacyRule)
  {
    this.rule = paramPrivacyRule;
  }

  public int getOrder()
  {
    return this.order;
  }

  public Type getType()
  {
    Type localType;
    if (getRule() == null)
      localType = null;
    while (true)
    {
      return localType;
      localType = getRule().getType();
    }
  }

  public String getValue()
  {
    String str;
    if (getRule() == null)
      str = null;
    while (true)
    {
      return str;
      str = getRule().getValue();
    }
  }

  public boolean isAllow()
  {
    return this.allow;
  }

  public boolean isFilterEverything()
  {
    int i;
    if ((isFilterIQ()) || (isFilterMessage()) || (isFilterPresence_in()) || (isFilterPresence_out()))
      i = 0;
    while (true)
    {
      return i;
      i = 1;
    }
  }

  public boolean isFilterIQ()
  {
    return this.filterIQ;
  }

  public boolean isFilterMessage()
  {
    return this.filterMessage;
  }

  public boolean isFilterPresence_in()
  {
    return this.filterPresence_in;
  }

  public boolean isFilterPresence_out()
  {
    return this.filterPresence_out;
  }

  public void setFilterIQ(boolean paramBoolean)
  {
    this.filterIQ = paramBoolean;
  }

  public void setFilterMessage(boolean paramBoolean)
  {
    this.filterMessage = paramBoolean;
  }

  public void setFilterPresence_in(boolean paramBoolean)
  {
    this.filterPresence_in = paramBoolean;
  }

  public void setFilterPresence_out(boolean paramBoolean)
  {
    this.filterPresence_out = paramBoolean;
  }

  public void setValue(String paramString)
  {
    if ((getRule() != null) || (paramString != null))
      getRule().setValue(paramString);
  }

  public String toXML()
  {
    StringBuilder localStringBuilder = new StringBuilder();
    localStringBuilder.append("<item");
    if (isAllow())
    {
      localStringBuilder.append(" action=\"allow\"");
      localStringBuilder.append(" order=\"").append(getOrder()).append("\"");
      if (getType() != null)
        localStringBuilder.append(" type=\"").append(getType()).append("\"");
      if (getValue() != null)
        localStringBuilder.append(" value=\"").append(getValue()).append("\"");
      if (!(isFilterEverything()))
        break label129;
      localStringBuilder.append("/>");
    }
    while (true)
    {
      while (true)
      {
        return localStringBuilder.toString();
        localStringBuilder.append(" action=\"deny\"");
      }
      label129: localStringBuilder.append(">");
      if (isFilterIQ())
        localStringBuilder.append("<iq/>");
      if (isFilterMessage())
        localStringBuilder.append("<message/>");
      if (isFilterPresence_in())
        localStringBuilder.append("<presence-in/>");
      if (isFilterPresence_out())
        localStringBuilder.append("<presence-out/>");
      localStringBuilder.append("</item>");
    }
  }

  public static class PrivacyRule
  {
    public static final String SUBSCRIPTION_BOTH = "both";
    public static final String SUBSCRIPTION_FROM = "from";
    public static final String SUBSCRIPTION_NONE = "none";
    public static final String SUBSCRIPTION_TO = "to";
    private PrivacyItem.Type type;
    private String value;

    protected static PrivacyRule fromString(String paramString)
    {
      Object localObject;
      if (paramString == null)
        localObject = null;
      while (true)
      {
        return localObject;
        PrivacyRule localPrivacyRule = new PrivacyRule();
        localPrivacyRule.setType(PrivacyItem.Type.valueOf(paramString.toLowerCase()));
        localObject = localPrivacyRule;
      }
    }

    private void setSuscriptionValue(String paramString)
    {
      String str;
      if ("both".equalsIgnoreCase(paramString))
        str = "both";
      while (true)
      {
        while (true)
        {
          while (true)
          {
            while (true)
            {
              this.value = str;
              return;
              if (!("to".equalsIgnoreCase(paramString)))
                break;
              str = "to";
            }
            if (!("from".equalsIgnoreCase(paramString)))
              break;
            str = "from";
          }
          if (!("none".equalsIgnoreCase(paramString)))
            break;
          str = "none";
        }
        str = null;
      }
    }

    private void setType(PrivacyItem.Type paramType)
    {
      this.type = paramType;
    }

    public PrivacyItem.Type getType()
    {
      return this.type;
    }

    public String getValue()
    {
      return this.value;
    }

    public boolean isSuscription()
    {
      int i;
      if (getType() == PrivacyItem.Type.subscription)
        i = 1;
      while (true)
      {
        return i;
        i = 0;
      }
    }

    protected void setValue(String paramString)
    {
      if (isSuscription())
        setSuscriptionValue(paramString);
      while (true)
      {
        return;
        this.value = paramString;
      }
    }
  }

  public static enum Type
  {
    static
    {
      Type[] arrayOfType = new Type[3];
      arrayOfType[0] = group;
      arrayOfType[1] = jid;
      arrayOfType[2] = subscription;
      ENUM$VALUES = arrayOfType;
    }
  }
}